<template>
  <div class="user-shares">
    <post-list
      :posts="posts"
      :loading="loading"
      @like="handleLike"
      @collect="handleCollect"
      @comment="handleComment"
    ></post-list>
  </div>
</template>

<script>
import PostList from '@/components/PostList.vue'
import axios from '@/config/http'

export default {
  name: 'UserShares',
  components: {
    PostList
  },
  data() {
    return {
      posts: [],
      loading: false
    }
  },
  created() {
    this.fetchSharedPosts()
  },
  methods: {
    async fetchSharedPosts() {
      this.loading = true
      try {
        const result = await axios.get('/pss/post/list', {
          params: {
            order: 1,
            pageNo: 1,
            pageSize: 10,
            isAsc: false,
            shared: true
          }
        })
        this.posts = result.data.data.data.list
      } catch (error) {
        console.error('获取转发的帖子失败:', error)
      } finally {
        this.loading = false
      }
    },
    handleLike(post) {
      // 处理点赞
    },
    handleCollect(post) {
      // 处理收藏
    },
    handleComment(post) {
      this.$router.push(`/post/${post.postId}`)
    }
  }
}
</script>

<style lang="less" scoped>
.user-shares {
  padding: 20px;
}
</style> 